<?php
	/**
	*Author 雷日锦 362606856@qq.com 
	*控制器自动生成
	*/
	if(!defined("ROOT_PATH")) exit("die Access ");
	class ymdian_productControl extends skymvc{
		public $oc_where;
		public function __construct(){
			parent::__construct();		
		}
		
		public function onInit(){
			$this->oc_where=M("login")->userid?" (userid=".M("login")->userid." or oc_ssid='".OC_SSID."')  ":"oc_ssid='".OC_SSID."' ";
		}
		
		public function onDefault(){
			$shopid=get_post('shopid','i');
			$where="shopid=".$shopid;
			$url="/index.php?m=ymdian_product&a=default";
			$limit=20;
			$start=get("per_page","i");
			$option=array(
				"start"=>intval(get_post('per_page')),
				"limit"=>$limit,
				"order"=>" id DESC",
				"where"=>$where
			);
			$rscount=true;
			$data=M("ymdian_product")->select($option,$rscount);
			$pagelist=$this->pagelist($rscount,$limit,$url);
			$this->smarty->assign(
				array(
					"data"=>$data,
					"pagelist"=>$pagelist,
					"rscount"=>$rscount,
					"url"=>$url
				)
			);
			$this->smarty->display("ymdian_product/index.html");
		}
		
		public function onSHow(){
			$id=get('id','i');
			$data=M('ymdian_product')->selectRow("id=".$id);
			if($data){
				$product=M('product')->selectRow("id=".$data['productid']);
				$product_data=M('product_data')->selectRow("id=".$data['productid']);
				$shop=M("ymdian")->selectRow("id=".$data['shopid']);
			}else{
				$this->goALl("参数出错",1);
			}
			$this->smarty->assign(array(
				"data"=>$data,
				"product"=>$product,
				"product_data"=>$product_data,
				"shop"=>$shop,
				"imgsdata"=>M("imgs")->get("product",$product['id'])
			));
			$this->smarty->display("ymdian_product/show.html");
		}
		
		 
		
	}

?>